﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="Users_Login" Title="Untitled Page" Codebehind="Login.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script src="../Include/JS/Lib/buttonfocus.js" type="text/javascript"></script>
<script src="../Include/JS/qq.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
//enter快捷键


document.onkeydown = KeyAccess;
function KeyAccess(e)
{
    if (document.all)
    {
        if(event.keyCode==13||event.keyCode==108)
        {
            if(document.activeElement.id=="SearchKey")
            {
                Search();
            }
            else
            {
                Login();
            }
              event.returnvalue = false;
        }
    }
}
function Login()
{
    var name=document.getElementById("Account");
    if(name.value.length<1)
    {
        alert('昵称不能为空');
        name.focus();
        return false;
    }
    var pwd=document.getElementById("pwd");
    if(pwd.length<1)
    {
        alert("密码不能为空");
        pwd.focus();
        return  false;
    }    
    Mask();
    document.getElementById("ShoppingCart").innerHTML="<br /><br />数据加载中......<br /><br /><img src='../images/ajax-loader.gif'>";    
    CallServer(name.value,pwd.value);
}
function Mask()
{ 
    var div_back = document.getElementById("div_background");
    div_back.style.display = "block"; 
    var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "block";  
    var sizeList = document.getElementById("alogin"); 
//    sizeList.removeAttribute("href"); 
//    sizeList.removeAttribute("onclick");   
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "block";
    cart.style.position = "absolute";
    var bigImg = document.getElementById("login");
    var pleft = 0;
    var ptop = 0;
   
    var obj = bigImg.offsetParent;
 
    while(obj.tagName != "BODY")
    {
         pleft = pleft + obj.offsetLeft;
         ptop = ptop + obj.offsetTop;
         obj = obj.offsetParent;
    }
    ptop = ptop + 150;
    cart.style.left = pleft +100+ "px";
    cart.style.top = ptop +"px";
    cart.style.width = 300 + "px";
    cart.style.backgroundColor  = "#ffffff";
}
function hide()
{
  var div_back = document.getElementById("div_background");
    div_back.style.display = "none"; 
     var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "none";  
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "none";    
}
function CallServer(UserCode,Pwd)  
{ 
      arg = UserCode+"|"+Pwd;   
      <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "")%>;   
}   
 function ReceiveServerData(result)   
 {  
    if(result.length<2)
    {
        alert("您输入的昵称与密码不匹配，请重新输入!");
        
        hide();
//        var sizeList = document.getElementById("alogin"); 
//            sizeList.href="Javascript:";
//            sizeList.onclick="Login()";
         
    }
    else
    {
        var back=document.getElementById("Hid_Back").value;
        if(back.length>0)
        {
            window.location.href=back;
        }
        else
        {
            window.location.href="../default.aspx";
        }
    }
    
 } 
 function BackUrl()
 {
    if(document.referrer.length>0)
    {
        document.getElementById("Hid_Back").value=document.referrer;
    }
 }
 function FindPwd()
 {
    if(document.all("Account").value=="")
    {
        alert("请输入昵称");
        document.all("Account").focus();
        return;
    }
    window.location.href="FindPwd.aspx?LogName="+document.getElementById("Text12").value;
 }
</script>
    <div class="r_content">
        <div class="r_gouwu">
            <div class="r_gouwu_title">
                <h2>
                    用户登录</h2>
            </div>
            <ul class="r_reg_icon2">
                <li>如您是第一次访问本网站，请点这里进行 ( <em><a href="Reg.aspx">注册</a></em> ) </li>
            </ul>
            <div class="r_kuang1" id="login">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="120" align="right">
                       
                                昵称：


                           </td>
                        <td>
                            <input id="Account" name="Text12" class="inputbox" style="width:160px;"/></td>
                    </tr>
                    <tr>
                        <td align="right">
                            密码：</td>
                        <td>
                            <input id="pwd" name="Text22" type="password" class="inputbox" style="width:160px;" onkeypress='buttonfocus(document.getElementById("alogin"),event)'/></td>
                    </tr>
                    <tr>
                        <td align="right">
                        </td>
                        <td>
                            <input id="CheckBox12" type="checkbox" name="CheckBox12" runat="server"/>
                            <label for="CheckBox12">
                                下次自动登录</label></td>
                    </tr>
                </table>
            </div>
            <div class="r_gouwu_button">
                <ul>
                    <li><a id="alogin" href="Javascript:" onclick="Login()"  >登录</a></li><li><a  href="Javascript:FindPwd()">忘记密码</a></li></ul>
                <input id="Hid_Back" type="hidden" />
            </div>
            <script>BackUrl();</script>
            <div class="clear">
            </div>
        </div>
    </div>
    <div id="div_background" class="divbackground" ><%--onclick="hide();"--%>
    </div>
    <iframe id="iframe_back" class="diviframe" frameborder="0"></iframe>
    <div id="ShoppingCart" style="z-index: 11; display: none">
    </div>
</asp:Content>
